package com.example.photoview;

import javafx.application.Application;
import javafx.beans.Observable;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Screen;
import javafx.stage.Stage;

import java.io.IOException;

public class Main extends Application {
    public static double width=1000;
    public static double height=600;

    @Override
    public void start(Stage stage) throws IOException {
       stage.setTitle("PhotoView");
       //根据屏幕自适应设置长宽

        try{
            Rectangle2D re=Screen.getScreens().get(0).getBounds();//获得屏幕大小的工具人
            width=re.getWidth()/1.35;
            height=re.getHeight()/1.35;
        }catch(Exception e){
            e.printStackTrace();
        }
        /*FXMLLoader loader=new FXMLLoader();
        loader.setLocation(getClass().getResource("/main/java/fxml/hello-view.fxml"));*/
        FXMLLoader loader = new FXMLLoader(Main.class.getResource("hello-view.fxml"));
        //Parent root= loader.load();
        Scene scene=new Scene(loader.load(),width,height);
        final ObservableList<String> stylesheets = scene.getStylesheets();
       // stylesheets.addAll(Main.class.getResource("css路径").toExternalForm());
        //stage.getIcons().add(new Image(Main.class.getResourceAsStream("/main/java/icon/app.png")));//最小化的图标
        //   stylesheets.addAll(Main.class.getResource("home.css").toExternalForm());
        //加载css样式文件
        stylesheets.addAll(Main.class.getResource("home.css").toExternalForm());
        stage.getIcons().add(new Image(Main.class.getResourceAsStream("app.png")));//最小化的图标
        stage.setScene(scene);
        stage.show();
    }
    //TODO 点击图片的框框和背景图标也要有菜单出现 应该是改下fx的事情
    public static void main(String[] args) {
        launch();
    }
}